package cn.edu.cdu.group4nb.controller;

import cn.edu.cdu.group4nb.po.Institution;
import cn.edu.cdu.group4nb.service.InstitutionService;
import cn.edu.cdu.group4nb.service.PositionService;
import cn.edu.cdu.group4nb.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class InstitutionController {
    @Autowired
    private InstitutionService institutionService;
    @ResponseBody
    @GetMapping("/InstitutionManager/selectInstitution")
    public List<Map<String, Object>> selectPosition (){
        return institutionService.selectInstitution();
    }

    @ResponseBody
    @PostMapping("/InstitutionManager/addInstitution")
    public Boolean insertInstitution(@RequestBody Institution institution){
        return institutionService.insertInstitution(institution);
    }
    @ResponseBody
    @PostMapping("/InstitutionManager/delInstitution")
    public Boolean stuDeleteCourse(@RequestBody int[] institution_id){
        return institutionService.delInstitution(institution_id);
    }
    @ResponseBody
    @PostMapping("/InstitutionManager/updInstitution")
    public Boolean updInstitution(@RequestBody Institution institution){
        String jsonResult =com.alibaba.fastjson.JSON.toJSONString(institution);
        System.out.print(jsonResult);
        return institutionService.updInstitution(institution);
    }
}
